//
//  MVVMCell.swift
//  HHSwift
//
//  Created by 华宏 on 2019/1/23.
//  Copyright © 2019年 huahong. All rights reserved.
//

import UIKit

class MVVMCell: UICollectionViewCell {
    var imageView:UIImageView!
    var titleLabel:UILabel!
    var model:MVVMModel?
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.contentView.backgroundColor = .white
        self.imageView = UIImageView()
        self.contentView.addSubview(self.imageView)
        
        self.titleLabel = UILabel()
        self.titleLabel.textAlignment = .center
        self.contentView.addSubview(self.titleLabel)
        
        setAutoLayout()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setAutoLayout() {
        self.imageView.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(self.imageView).multipliedBy(1)
        }
        
        self.titleLabel.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.top.equalTo(self.imageView.snp.bottom)
            make.bottom.equalToSuperview()
        }
    }
    
    override func prepareForReuse() {
        self.imageView.image = nil
        self.titleLabel.text = ""
    }
    
    
}
